Qute: A Prolog/Lisp Type Language for Logic Programming

نویسندگان

  • Masahiko Sato
  • Takafumi Sakurai
چکیده

A new Prolog/Lisp type programming language called Qute is introduced. Qute computes (partial) recursive functions on the domain S of symbolic expressions in the sense of Sato[3], Sato and Hagiya[4]. Qute amalgamates Prolog and Lisp in a natural way. Any expression that is meaningful to Qute is either a Prolog expression or a Lisp expression and a Prolog (Lisp) expression is handled by the Prolog (Lisp, resp.) part of Qute. Moreover, the Prolog-part and the Lisp-part calls each other recursively. Compared with the traditional Lisp symbolic expressions, our symbolic expressions are mathemati­ cally much neater and yet constitute a richer domain. Qute is a theoretically well-founded language defined on this domain of symbolic expressions. Many interesting features of Qute are described in this paper. Qute has been implemented on VAX /UNIX and is used to develop a programming system for proving pro­ perties of our domain of symbolic expressions. 0. Introduction In this paper, we introduce a new Prolog/Lisp type programming language called Qute that is designed to compute (partial) recursive functions on the domain S of symbolic expressions in the sense of Sato [3], Sato and Hagiya[4]. Since Qute combines the features of Prolog and Lisp quite naturally, it provides a comfortable environ­ ment for developing programs interactively. Users of Qute can not only enjoy both Prolog and Lisp style pro­ gramming but also combine them in a unique way. To be more precise, any expression that is mean­ ingful to Qute is either a Prolog expression or a Lisp expression. A Prolog expression may contain Lisp expressions as its subexpressions and conversely a Lisp expression may contain Prolog expressions as its subex­ pressions. Prolog (Lisp) expression is handled by the Prolog (Lisp, resp.) part of Qute. In this way, the Prolog-part naturally contains the Lisp-part and the Lisp-part contains the Prolog-part. This paper is based on the result of activities of working groups for the Fifth Generation Computer Systems Projects. Another characteristic feature of Qute is that, like Lisp but unlike Prolog, symbolic expressions play the double role of data and programs. It is therefore possi­ ble to write a simple metacircular interpreter of Qute by Qute itself. In fact, we can write the interpreter using only the Prolog-part of Qute. The interpreter of Qute can be defined formally by inductive definitions as we did for Hyperlisp[3]. This makes Qute a theoretically well-founded language. In this paper, however, due partly to the limitation of space, we will describe the semantics of Qute rather informally. LOGLISP[l] takes a similar approach towards combination of Prolog and Lisp, but our concern centers on formalism which we slightly mentioned above. Therefore, we designed Qute so that programs can be naturally regarded as symbolic expressions. (As is explained later, we regard a 'variable' as a symbolic expression unlike usual Prolog.) Qute has been implemented on V A X / U N I X at the Computer Centre of the University of Tokyo. The language is used to develop a programming system for proving properties of our domain of symbolic expres­ sions. Properties of Qute will be expressed and verified in the system. See Sakurai [2] for more details of the project. In the rest of the paper, we first review our domain S briefly and then describe the syntax and semantics of Qute. Many interesting features of the language will be described along the way. 1. Symbolic Expression 1.1. definition of sexp Symbolic expressions (sexps, for short) are con­ structed by the following clauses: 1. 0 is a sexp. 2. If s and t are sexps then snoc(s, t) is a sexp. 3. If s and t are sexps and at least one of them is not 0 then cons(s, t) is a sexp. All the sexps are constructed only by means of the iterated applications of the above three clauses, and sexps constructed differently are distinct. We denote the set of all the sexps by S. Note that snoc is a total function on SxS while cons is partial since it is undefined for the argument (O, 0). We make cons total by stipulating that cons(0, 0) 0. We also put snoc(0, 0) 1. 508 M. Sato and T. Sakurai M. Sato and T. Sakurai 509 is called a special sexp. We use V A R , QUOTE, Q Q U O T E , ESC, E V A L respectively to denote the above atoms. A sexp which does not contain a special sexp as its sub-sexp is called a constant sexp or simply a constant. We now explain the function eval that is used to evaluate Lisp expressions. The function eval is defined so that it preserves cons and snoc for non-special sexps and hence it becomes an identity function on constants. Therefore, we can make use of snoc (and cons which satisfies ( r3)) as a pattern constructor. This advantage comes f rom the fact that we have two constructors snoc and cons. 510 M. Sato and T. Sakurai M. Sato and T. Sakurai 511 where prem is caar and ant is cadar. This describes only the pure part of eval. Qute has a built-in function 'set' which can change the environ­ ment. (We omit the explanation in this paper.) 3. The Prolog-part of Qute The Prolog-part of Qute is similar to an ordinary Prolog, but there is an important difference, i.e., the argument list of the predicate and the parameter list of the assertion are evaluated before they are unified with the assertions. We give examples in 3.1, explain syntax of Qute in 3.2 and mechanism of unification in 3.3, 3.4. 512 M. Sato and T. Sakurai When a sexp / is evaluated, it is necessary to know the values of the free variables in /. However, the intended meaning of a free variable in a predicate is an unknown sexp which may be known after evalua­ tion. We introduce the notion of an undefined value (it is an imaginary element outside of S). We suppose that each free variable has a different undefined value. 3.4. unification Before evaluating the predicates in a goal, an environment which is a list of pairs of a free variable and an undefined value is set up. Before an unification is made with a predicate definition, an environment is set up similarly, using free variables in the parameter and the body of the predicate definition. An undefined value plays the role of a 'variable' in unification.

برای دانلود متن کامل این مقاله و بیش از 32 میلیون مقاله دیگر ابتدا ثبت نام کنید

ثبت نام

اگر عضو سایت هستید لطفا وارد حساب کاربری خود شوید

منابع مشابه

PROLOG: a language for implementing expert systems

We briefly describe the logic programming language PROLOG concentrating on those aspects of the language that make it suitable for implementing expert systems. We show how features of expert systems such as: (1) inference generated requests for data, (2) probabilistic reasoning, (3) explanation of behaviour can be easily programmed in PROLOG. We illustrate each of these features by showing how ...

متن کامل

A Data Base Extension of Prolog and its Implementation

A method is presented to extend the programming language Prolog with a capability to access a relational data base system. Since the data type ‘relation' is basic in Prolog, and since Prolog is based on interpretation of a subset of predicate calculus, such an interface becomes simpler in Prolog than in most other languages, and the same language, extended Prolog, may be used both for programmi...

متن کامل

Tablog: Functional and Relational Programming in One Framework

Tablog12 is a logic programming ing languages, given their emphasis on A program in Tablog is a list of forlanguage that combines functional and using predicates to describe computamulas in quantifier-free, first-order relational programming into a unified tions. logic with equality and is usually more framework. It incorporates advanAn even broader definition of the natural than the correspond...

متن کامل

A Tiny Specification Metalanguage

A logic programming language with potential software engineering benefit is described. The language is intended as a specification language where the user specifies software functionality while ignoring efficiency. The goals of the language are: (1) a pure specification language – “what, not how”, (2) small size, and (3) a metalanguage – able to imitate and thus subsume other languages. The lan...

متن کامل

HCPRVR: An Interpreter for Logic Programs

An overview of a logic program interpreter written in Lisp is presented. The interpreter is a Horn clause-based theorem prover augmented by Lisp functions attached to some predicate names. Its application to natural language processing is discussed. The theory of operation is explained, including the high level organization of the PROVE function and an efficient version of unification. The pape...

متن کامل

ذخیره در منابع من


  با ذخیره ی این منبع در منابع من، دسترسی به آن را برای استفاده های بعدی آسان تر کنید

برای دانلود متن کامل این مقاله و بیش از 32 میلیون مقاله دیگر ابتدا ثبت نام کنید

ثبت نام

اگر عضو سایت هستید لطفا وارد حساب کاربری خود شوید

عنوان ژورنال:

دوره   شماره 

صفحات  -

تاریخ انتشار 1983